/*loader
 The 2112Portals JS Loader:
 -encapsulating the loader functionality to be able to substitute it by different frameworks
 -Maximum control
 -Most flexible
 A snapIn needs to have a load function to be hooked up by the portal system.

*/




//alert(runIsolated) ;
window.NS2112 = window.NS2112 || {};


NS2112.namespace("INTRINSICS") ;

NS2112.INTRINSICS.LoaderData = function(strName, strType, strPath, strFullPath)
{

   this.name = strName ;
   this.type = strType ;
   this.path = strPath;
   this.fullpath = strFullPath;

/*
name: 
required, the component name 
type: 
required, the component type (js or css) 
path: 
required, the path to the script from "base" 
requires: 
the modules required by this component 
optional: 
the optional modules for this component 
supersedes: 
the modules this component replaces 
rollup: 
the number of superseded modules required for automatic rollup 
fullpath: 
If fullpath is specified, this is used instead of the configured base + path 
skinnable: 
flag to determine if skin assets should automatically be pulled in 
*/

}

NS2112.LoaderFactory12 = function(strBaseURI)
{        
   var m_rModules ;
   var m_baseURI = strBaseURI ;
   this.loaderCallback = function(o){
      //o.data.mc.postRegisterSnap(o.data.theSnap, o.data.strSnapID) ;     
     // alert('loaderCallback success') ;
      this.loadNext() ;
   }
   
   this.loadNext = function() 
   {
      
      if(m_rModules.length > 0)
      {  
         this.loadModule(null, m_rModules[0], m_rModules[0]) ;
         m_rModules.splice(0,1) ;
      }
   }

      
   this.loadModule = function (oMC, strModuleName, strModuleURL) 
   {
       var Loader = new YAHOO.util.YUILoader({
           scope: this,
           onFailure: function(o) {
            alert("error: " + YAHOO.lang.dump(o));
        }

     });
     
     Loader.data = new Object ;
     Loader.data["test"] = 'TEST' ;
     Loader.data["mc"] = oMC;
     Loader.onSuccess = this.loaderCallback ;
     var ld = new NS2112.INTRINSICS.LoaderData(strModuleName, 'js', '', strModuleURL) ;
     Loader.addModule(ld) ;
     Loader.require(strModuleName); //include the new  module
     Loader.insert({
        onSuccess: this.loaderCallback
    });
   }  

   this.loadModules = function(rModules)
   {
      m_rModules = rModules;
      this.loadNext() ;
   }

}




